import http from "../http";

export const getCourse = (id?: string) =>
  http.get("/teaching/course/selectByCreatedBy", { params: { createdBy: id } });

export const saveCourse = (data: any) =>
  http.post("/teaching/course/saveCourse", data);

export const publishTask = (data: any) =>
  http.post("/teaching/course-homework/publishCourseHomework", data);


export const deleteTaskById = (id: string) =>
  http.get("/teaching/course-homework/deleteById", {
    params: { id: id },
  });
  export const updateTask = (data: any) =>
    http.post("/teaching/course-homework/updateCourseHomeworkDes", data);


export const getCourses = (id: string) =>
  http.get("/teaching/course-homework/selectByCreateBy", {
    params: { courseId: id },
  });

export const queryTaskList = (courseId: string) =>
  http.get("/teaching/course-homework/selectByCourseId", {
    params: { courseId },
  });

export const getCourseHomework = (courseId: string) =>
  http.get("/teaching/course-homework/selectByCourseId", {
    params: { courseId },
  });

export const getHomeworkById = (id: string) =>
  http.get("/teaching/course-homework/selectByCreateBy", {
    params: { createBy: id },
  });

export const getStudentHomework = (courseHomeworkId: string) =>
  http.get("/teaching/student-homework/listByCourseHomeworkId", {
    params: { courseHomeworkId },
  });

export const studentSubmitHomework = (data: any) =>
  http.post("/teaching/student-homework/submitHomework", data);

// 通过课程作业id查询作业
export const getHomeworkByCourseHomeworkId = (
  courseHomeworkId: string,
  userId: string
) =>
  http.get("/teaching/student-homework/listByCourseHomeworkIdAndUserId", {
    params: { courseHomeworkId, userId },
  });

// 查询带评审学生作业列表
export const getHomeworkByCourseHomeworkIdAndStatus = (
  courseHomeworkId: string
) =>
  http.get("/teaching/student-homework/selectGradingAssignments", {
    params: { courseHomeworkId },
  });

// 批改作业
export const correctHomework = (data: any) =>
  http.post("/teaching/student-homework/gradingAssignments", data);


export const getHomeworkListByCourseId = (courseHomeworkId) =>
  http.get("/teaching/student-homework/listByCourseId", {
    params: { courseHomeworkId },
  });

// 发布签到
export const publishSignIn = (desc: any) =>
  http.get("/teaching/publish-sign-in/publishSignIn", { params: { desc } });

// 查询发布的签到信息
export const getPublishSignIn = (courseId: any) =>
  http.get("/teaching/publish-sign-in/selectCurrentUserPublish", {
    params: { courseId },
  });

// 查询没有签到的信息
export const getNoSignIn = () =>
  http.get("/teaching/publish-sign-in/currentUserNoSignIn");

// 进行签到
export const doSignIn = (publishSignInId: any) =>
  http.get("/teaching/publish-sign-in/signIn", {
    params: { publishSignInId },
  });

// 删除课程
export const deleteCourseById = (id: any) =>
  http.get("/teaching/course/deleteCourse", {
    params: { id },
  });
